<?php
    $username = $_GET["username"];
    $pwd = $_GET["pwd"];

    if(strlen($username)>0 && strlen($pwd)>0)
    {
        $con = mysql_connect('localhost','root','chenpo');
        if(!$con)
        {
            die('数据库连接有误:'.mysql_error());
        }
        mysql_select_db("reader",$con);
        $sql_checkuser = "select count(user_id) from user where user_name='".$username."'";
        $result_checkuser = mysql_fetch_array(mysql_query($sql_checkuser));
        //echo $sql_checkuser."\n";
        //echo $result_checkuser[0];
        if($result_checkuser[0]>0)
        {
            die('用户已经存在！');
        }
        else
        {
            $sql_insertuser = "insert into user(user_name,user_pwd) values('".$username."',password('".$pwd."'))";
            $result_insertuser = mysql_query($sql_insertuser);
            if($result_insertuser)
            {
                echo $username."用户注册成功！";
            }
            else
            {
                echo "用户注册失败...";
            }
        }
        mysql_close($con);
    }
?>